# Maintainer: Diego Sogari <diego.sogari@gmail.com>

_realname=clucene
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.3.3.4
pkgrel=1
pkgdesc="CLucene - a C++ search engine (mingw-w64)"
arch=('any')
url="https://clucene.sourceforge.io/"
license=('LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake")
depends=("${MINGW_PACKAGE_PREFIX}-boost" "${MINGW_PACKAGE_PREFIX}-zlib")
source=("https://downloads.sourceforge.net/project/${_realname}/${_realname}-core-unstable/${pkgver:0:3}/${_realname}-core-${pkgver}.tar.gz"
        "${_realname}-core-${pkgver}.patch")
sha256sums=('ddfdc433dd8ad31b5c5819cc4404a8d2127472a3b720d3e744e8c51d79732eab'
            'a3b0bb664231ed5e66384dd606422d7f6d9f0e6181f295056acfbe0b0d4d7c9c')

prepare() {
  cd "${srcdir}/${_realname}-core-${pkgver}"
  patch -Np1 -i "../${_realname}-core-${pkgver}.patch"
}

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DBUILD_STATIC_LIBRARIES=ON \
    -DCMAKE_BUILD_TYPE=Release \
    "../${_realname}-core-${pkgver}"

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
